package kr.hkit.powerjava.chapter08;

/**은행 계좌
 * owner = 소유주
 * accountNumber = 계좌번호
 * balance = 잔액
 * @author M201_08
 *
 */
public class BankAccount {
	private String owner;
	private int accountNumber;
	private int balance;
	
	public BankAccount(String owner, int accountNumber, int balance){
		this.owner = owner;
		this.accountNumber = accountNumber;
		this.balance = balance;
	}
	
	/**예금
	 * @param amount : 입금액
	 */
	public void deposit(int amount){
		balance = balance + amount;
	}
	

	/**출금
	 * @param amount 
	 */
	public int withdraw(int amount){
		if(balance < amount || balance == 0 ){
			System.out.println("출금 불가");
			return -1;
		}else {
			balance = balance - amount;
			return amount;
		}
	
	}
	@Override
	public String toString() {
		return "BankAccount [owner=" + owner + ", accountNumber="
				+ accountNumber + ", balance=" + balance + "]";
	}

}
